//
// Created by 喵喵乐 on 2023/4/22.
//

#include "string_bad.h"

string_bad::string_bad(const char *a) {

    len = std::strlen(a);
    str = new char[len + 1];
    num_strings++;
    std::cout << num_strings << ": \"" << str << "\" object create \n";
}

string_bad::string_bad() {
    len = 4;
    str = new char[4];
    std::strcpy(str, "C++");
    num_strings++;
    std::cout << num_strings << ": \"" << str << "\" default object created\n";
}

string_bad::~string_bad() {
    std::cout << "\"" << str << "\"object deleted,";
    --num_strings;
    std::cout << num_strings << "left\n";
    delete[] str;
}
